#include <bits/stdc++.h>
using namespace std;
bool judge(int a)
{
    if (a <= 1)
        return false;
    for (int i = 2; i * i <= a; i++)
    {
        if (a % i == 0)
            return false;
    }
    return true;
}
int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = a; i <= b; i++)
    {
        int newa = 10 * (i % 10) + i / 10;
        if (judge(i) && judge(newa))
            cout << i << endl;
    }

    return 0;
}